//
//  BarrageView.swift
//  V1_vodone
//
//  Created by maliang on 2017/4/22.
//  Copyright © 2017年 Arvinma. All rights reserved.
//

import UIKit

fileprivate let defaultSpeed = CGFloat(1)
fileprivate let defaultSpeedWidth = CGFloat(300)

class BarrageView: UIView {

    let textLB = UILabel()
    var rowNo:Int = 0
    var text:String?
    var isShowComplete:Bool = false
    
    class func barrageViewWith(text:String,rowNo:Int) -> BarrageView{
    
        let barrageView = BarrageView()
        barrageView.text = text
        barrageView.rowNo = rowNo
        barrageView.setUpView()
        return barrageView
    }
    
    fileprivate func setUpView(){
    
        self.textLB.text = self.text
        self.textLB.sizeToFit()
        self.addSubview(self.textLB)
        self.width = self.textLB.width
        self.height = self.textLB.height
        self.backgroundColor = UIColor.blue
        self.alpha = 0.6
    }
    
    func speed() -> CGFloat{
    
        return defaultSpeed + (self.width / defaultSpeedWidth)
    }
    
    func offSet() -> CGFloat{
    
        return CGFloat(arc4random() % 80)
    }
}
